package com.dingli.admin.service.impl;


import com.dingli.admin.service.InsertUser;
import com.dingli.framework.entity.User;
import com.dingli.framework.mapper.UserMapper;
import com.dingli.framework.util.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InsertUserImpl implements InsertUser {
    @Autowired
    private UserMapper userMapper;

    @Override
    public Response insertUser(String name, String password) {
        List<User> user = userMapper.getUser(name);
        if (user.size() != 0) {
            return new Response(500, "用户已存在");
        } else {
            int i = userMapper.insertUser(name, password);
            if (i == 0) {
                return new Response(500, "添加失败");
            }
            return new Response(200, "添加成功", i);
        }
    }

}
